import 'package:aliyun_vod_upload/model/UploadFileInfoModel.dart';
import 'package:aliyun_vod_upload/model/vodInfoModel.dart';
import 'package:aliyun_vod_upload/model/vodUploadResultModel.dart';

typedef OnUploadFinishedListener = Function(UploadFileInfoModel, VodUploadResultModel);
typedef OnUploadFailedListener = Function(UploadFileInfoModel, String, String);
typedef OnUploadProgressListener = Function(UploadFileInfoModel, int, int);
typedef OnUploadTokenExpiredListener = Function();
typedef OnUploadRertyListener = Function();
typedef OnUploadRertyResumeListener = Function();
typedef OnUploadStartedListener = Function(UploadFileInfoModel);

abstract class Enum<T> {
  final T value;

  const Enum(this.value);
}

class Event extends Enum<String> {
  const Event._(String val) : super(val);

  factory Event(String val) {
    if (val == finished.value) {
      return finished;
    } else if (val == failed.value) {
      return failed;
    } else if (val == progress.value) {
      return progress;
    } else if (val == tokenExpired.value) {
      return tokenExpired;
    } else if (val == rerty.value) {
      return rerty;
    } else if (val == rertyResume.value) {
      return rertyResume;
    } else if (val == started.value) {
      return started;
    }
    throw Exception('$val is not a valid value for FlightScheduleStatus.');
  }

  static const finished = Event._('OnUploadFinishedListener');
  static const failed = Event._('OnUploadFailedListener');
  static const progress = Event._('OnUploadProgressListener');
  static const tokenExpired = Event._('OnUploadTokenExpiredListener');
  static const rerty = Event._('OnUploadRertyListener');
  static const rertyResume = Event._('OnUploadRertyResumeListener');
  static const started = Event._('OnUploadStartedListener');
}